<?php

namespace app\controller;

use app\constants\RsaConstant;
use app\traits\ControllerTrait;
use Qiniu\Auth;

class QiNiuCloudUpload extends ControllerTrait
{
    public function Index()
    {

    }

    private function Auth()
    {
        // 用于签名的公钥和私钥
        $accessKey = RsaConstant::QI_NIU_ACCESS_KEY;
        $secretKey = RsaConstant::QI_NIU_SECRET_KEY;
        $auth = new Auth($accessKey, $secretKey);
        return $auth;
    }

    public function Token()
    {
        // 初始化签权对象
        $auth = $this->Auth();
        $bucket = RsaConstant::QI_NIU_BUCKET;
        $token = array(
            "token" => $auth->uploadToken($bucket)
        );
        $this->success($token, "assetToken获取成功");
    }

}